<?php
namespace Home\Controller;
use Think\Controller;
use Utils\RongUtils;
class TipController extends Controller {
    public function waitforread(){
        $m=D("Tip");
        $count= $m->where(array("isread"=>"待阅"))->count();
        $Page= new \Think\Page($count,10);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','共%TOTAL_ROW%条%TOTAL_PAGE%页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('link','indexpagenumb');//pagenumb 会替换成页码
        $Page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER% ');
        $show= $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = $m->limit($Page->firstRow.','.$Page->listRows)->where(array("isread"=>"待阅"))->select();
        $this->assign("start", $Page->firstRow);
        $this->assign('list',$list);// 赋值数据集
        $this->assign('page',$show);// 赋值分页输出
        $this->display();
      
    }
    public function alreadyread(){
        $m=D("Tip");
        $count= $m->where(array("isread"=>"已阅"))->count();
        $Page= new \Think\Page($count,10);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','共%TOTAL_ROW%条%TOTAL_PAGE%页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('link','indexpagenumb');//pagenumb 会替换成页码
        $Page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER% ');
        $show= $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = $m->limit($Page->firstRow.','.$Page->listRows)->where(array("isread"=>"已阅"))->select();
        $this->assign("start", $Page->firstRow);
        $this->assign('list',$list);// 赋值数据集
        $this->assign('page',$show);// 赋值分页输出
        $this->display();
    }
   public function read($id) {
        $m=D("Tip");
        if($m->save(array("no"=>$id,"isread"=>"已阅"))){
            $this->redirect("Tip/waitforread",0);
        }
        
   }
}